package com.gqb.wangyi;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNextInt()) {// 注意while处理多个case
			Integer num = in.nextInt();
			if (num > 0 && num < 10000) {
				List<Integer> array = new ArrayList<Integer>();
				while (num / 10 > 0) {
					array.add(num % 10);
					num = num / 10;
				}
				array.add(num);
				Collections.sort(array);
				int num1 = getNumL(array);
				int num2 = getNumS(array);
				int cha = num1 - num2;
				if (cha == 0) {
					System.out.println(num1 + "-" + num2 + "=0000");
				} else {
					while (cha != 6174) {
						System.out.println(num1 + "-" + num2 + "=" + cha);
						array = getArray(cha);
						Collections.sort(array);
						num1 = getNumL(array);
						num2 = getNumS(array);
						cha = num1 - num2;
					}
					System.out.println(num1 + "-" + num2 + "=" + cha);
				}
			} else {
				break;
			}
		}
	}

	public static List<Integer> getArray(int num) {
		List<Integer> array = new ArrayList<Integer>();
		while (num / 10 > 0) {
			array.add(num % 10);
			num = num / 10;
		}
		array.add(num);
		return array;
	}

	public static int getNumS(List<Integer> datas) {
		int size = datas.size() - 1;
		int num = 0;
		for (int i = 0; i < datas.size(); i++) {
			num += (int) (datas.get(i) * Math.pow(10, size--));
		}
		return num;
	}

	public static int getNumL(List<Integer> datas) {
		int size = datas.size() - 1;
		int num = 0;
		for (int i = datas.size() - 1; i >= 0; i--) {
			num += (int) (datas.get(i) * Math.pow(10, size--));
		}
		return num;
	}

}